/*
https://mp.csdn.net/mp_blog/creation/editor/138558365?spm=1001.2014.3001.4503
*/

#include <stdio.h>
#include <string.h>

int main() {
    int n = 0;
    scanf("%d",&n);
    for(int x = 0; x < n; ++x){
        char password[100] = {0};
        scanf("%s",password);
        int length = strlen(password);
        //记录各种类型出现的次数
        int count_num = 0;
        int count_up = 0;
        int count_down = 0;
        for(int i = 0; i < length; ++i ){
            if(length < 8){
                printf("NO\n");
                break;
            }
            else if(password[0] >= '0' && password[0] <= '9') 
            {
                printf("NO\n");
                break;
            }
            if(password[i] >= '0' && password[i] <= '9'){
                count_num++;
            }
            else if(password[i] >= 'a' && password[i] <= 'z'){
                count_down++;
            }
            else if(password[i] >= 'A' && password[i] <= 'Z'){
                count_up++;
            }
            else{
                printf("NO\n");
                break;
            }
        }
        if(count_num + count_down + count_up == length){
            if((count_num > 0 ) + (count_down > 0) + (count_up > 0) >= 2){
                printf("YES\n");
            }
            else {
                printf("NO\n");
            }
        }
    }
    return 0;
}
